#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    bool isArt(const vector<int> &v)
    {
        int a = v[1] - v[0];
        for (int i = 2; i < v.size(); ++i)
        {
            if (v[i] - v[i - 1] != a)
            {
                return false;
            }
        }
        return true;
    }
    vector<bool> checkArithmeticSubarrays(vector<int> &nums, vector<int> &l, vector<int> &r)
    {
        vector<bool> ret;
        for (int i = 0; i < l.size(); ++i)
        {
            if (r[i] - l[i] < 1)
            {
                ret.push_back(false);
            }
            else
            {
                vector<int> tmp(nums.begin() + l[i], nums.begin() + (r[i] + 1));
                sort(tmp.begin(), tmp.end());
                ret.push_back(isArt(tmp));
            }
        }
        return ret;
    }
};